package org.wxl.comment;

/**
 * 角色枚举
 * @author wxl
 */
public enum RoleEnum {
    ADMIN("ROLE_ADMIN","管理员"),
    USER("ROLE_USER","普通用户"),
    BLOGGER("ROLE_BLOGGER","视频博主");

    private final String role;
    private final String roleName;

    RoleEnum(String role, String roleName) {
        this.role = role;
        this.roleName = roleName;
    }

    public String getRole() {
        return role;
    }

    public String getRoleName() {
        return roleName;
    }
    public static RoleEnum fromRole(String role) {
        for (RoleEnum roleEnum : RoleEnum.values()) {
            if (roleEnum.role.equals(role)) {
                return roleEnum;
            }
        }
        throw new IllegalArgumentException("未知角色标识: " + role);
    }
    public boolean isAdmin() {
        return this == ADMIN;
    }

    public boolean isBlogger() {
        return this == BLOGGER;
    }
}
